package com.czk.redis;

import com.czk.domain.MsgAgreement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/4/29 11:30
 */
@Component
public class Publisher {
    private final RedisTemplate<String, Object> redisMessageTemplate;

    /**
     * 构造方法注入
     *
     * @param redisMessageTemplate
     */
    @Autowired
    public Publisher(RedisTemplate<String, Object> redisMessageTemplate) {
        this.redisMessageTemplate = redisMessageTemplate;
    }

    public void pushMessage(String topic, MsgAgreement message) {
        redisMessageTemplate.convertAndSend(topic, message);
    }

}
